public class Item {
    private char operator;
    private double random;
    private int itemtype;
    
    public Item() {
		
    }
    
    public Item(char opr) {
	operator = opr;
	itemtype = 2; //its function    
    }

    public Item(double rnd) {
	itemtype = 0; //random
	random = rnd;
    }

    public Item(int xitem) {
	if(xitem == 1)
	    itemtype = xitem; //creates an xitem
	else
	    System.out.println("Only x item can be created using this constructor.");
    }
    
    public void setOperator (char opr) {
	if(opr != 'x')   
	    { 
		itemtype = 2;	    
		operator = opr;
	    }
    }

    public void setRandom (double rnd) {
	itemtype = 0;	    
	random = rnd;
    }
    
    public char getOperator () {
	    return operator;
    }

    public char getX () {
	return 'x';
    }
    
    public double getRandom () {
	return random;
    }
    
    public int getNodeType () {
	return itemtype;
	}
    
    public void printNode () {
	if(itemtype == 0)
	    System.out.print(random);
	else if(itemtype == 1)
	    System.out.print('x');
	else if(itemtype == 2)
	    System.out.print(operator);
	else
	    System.out.println("No node is assigned.");
    }
    
}
